package logic

import (
	"context"
	"person/models"

	"person/personrpc/internal/svc"
	"person/personrpc/personrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DetailLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DetailLogic {
	return &DetailLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 详情
func (l *DetailLogic) Detail(in *personrpc.DetailRequest) (*personrpc.DetailResponse, error) {
	// todo: add your logic here and delete this line

	var user models.User
	if err := user.UserDetail(models.DB, in.UserId); err != nil {
		return nil, err
	}
	return &personrpc.DetailResponse{
		Mobile:   user.Mobile,
		Password: user.Password,
	}, nil
}
